package _20_diedaiqi_pattern;

import java.util.ArrayList;

/**
 * @Description: 项目迭代器
 * @Auther: 2019/5/30 14:58 by zhang.jy
 */
public class ProjectIterator implements IProjectIterator {
	//所有的项目都放在ArrayList中
	private ArrayList<IProject> projectList = new ArrayList<IProject>();
	private int currentItem = 0;

	//构造函数传入projectList
	public ProjectIterator(ArrayList<IProject> _projectList) {
		this.projectList = _projectList;
	}

	//判断是否还有元素，必须实现
	@Override
	public boolean hasNext() {
		//定义一个返回值
		boolean b = true;
		if ( this.currentItem >= projectList.size() || this.projectList.get(this.currentItem) == null){
			b = false;
		}
		return b;
}

	//取得下一个值
	@Override
	public IProject next() {
		return (IProject) this.projectList.get(this.currentItem++);
	}

	//删除一个对象
	@Override
	public void remove() {
		//暂时没有使用到
	}
}